package ui.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import ui.service.IndexService;

import javax.servlet.http.HttpServlet;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by qiang.yu on 2016/12/27.
 */
@Controller
@RequestMapping("/index")
public class IndexController extends HttpServlet{

    @Autowired
    private IndexService indexService;

    @RequestMapping("/init")
    public ModelAndView initIndex() {
        ModelAndView mav = new ModelAndView();
        mav.setViewName("index/inputShow");
        return mav;
    }

    @RequestMapping("/userlist")
    @ResponseBody
    public Map<String,Object> getAllUserInfo(){
        Map<String,Object> mav = new HashMap<String, Object>();
        mav.put("rows",indexService.getAllUserInfo());
        mav.put("total",indexService.getAllUserInfo().size());
        return mav;
    }

}
